package com.bwie.list.controller;

import com.bwie.common.domain.Car;
import com.bwie.common.domain.Type;
import com.bwie.common.domain.request.CarVO;
import com.bwie.common.result.Result;
import com.bwie.list.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/list")
public class CarController {
    @Autowired
    private CarService carService;

    @PostMapping("/findListAll")
    public Result<List<Car>> findListAll(){
        List<Car> list = carService.findListAll();
        Result<List<Car>> result = Result.success(list);
        return result;
    }

    /**
     * 车辆列表
     */
    @PostMapping("/findCarList")
    public Result<List<Car>> findCarList(@RequestBody CarVO carVO){
        List<Car> list = carService.findCarList(carVO);
        Result<List<Car>> result = Result.success(list);
        return result;
    }


    /**
     * 车辆类型列表
     */

    @PostMapping("/findTypeList")
    public Result<List<Type>> findTypeList(){
        List<Type> list = carService.findTypeList();
        Result<List<Type>> result = Result.success(list);
        return result;
    }

    /**
     *登记
     */
    @PostMapping("/add")
    public Result add(@RequestBody Car car){
        carService.add(car);
        return Result.success();
    }


    /**
     *进校园登记
     */
    @PostMapping("/update")
    public Result update(@RequestBody Car car){
        carService.update(car);
        return Result.success();
    }

    /**
     *出校园登记
     */
    @PostMapping("/update1")
    public Result update1(@RequestBody Car car){
        carService.update1(car);
        return Result.success();
    }
}
